{% load static %}
<html>
<head>
<title>login</title>
    <!-- 引入 layui.css -->
    <link href="{%static '/css/layui.css'%}" rel="stylesheet">
    <link href="{%static '/css/index.css'%}" rel="stylesheet">
    <!-- 引入 layui.js -->
    <script src="{%static '/lib/layui/layui.js'%}" charset="utf-8"></script>
<style>
.demo-login-container{width: 320px; margin: 21px auto 0;}
.demo-login-other .layui-icon{position: relative; display: inline-block; margin: 0 2px; top: 2px; font-size: 26px;}
</style>

<script type="text/javascript">
	layui.use([ 'jquery', 'layer' ],function() {
        var $ = layui.jquery;
        var layer = layui.layer;
        $("#btnlogin").click(function(){
           url = "/api/user/loginhistory/"
           $.ajax({
               url:url,
               type:'post',
               data:{
                   "username":$("#username").val(),
                   "pwd":$("#pwd").val()
               },
               dataType:"json",
               success:function(res){
                   if(res.code==200){
                       layer.msg(res.msg,{icon:1,time:2*1000,shade:0.4},function(){
                           location.href="/index";
                       });
                   }
                   else{
                       layer.msg(res.msg,{time:2*1000});
                   }
               },
               error:function(err){
                   layer.msg("登录错误",{time:2*1000});
               }
           });
        });
    });
</script>
</head>
<body class="tx-login-bg">
	<div id="fullscreen">
        <div style="width:100%;height:80%;margin:0 0 auto auto;">
            <div class="layui-form" style="margin-top:150px;">
                <div class="demo-login-container">
                    <div class="layui-input-wrap">
                        <div class="layui-input-prefix">
                            <i class="layui-icon layui-icon-username"></i>
                        </div>
                        <input type="text" id="username" name="username" value="{{username}}" lay-verify="required" placeholder="用户名"  lay-reqtext="请填写用户名" autocomplete="off" class="layui-input" lay-affix="clear">
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-wrap">
                            <div class="layui-input-prefix">
                              <i class="layui-icon layui-icon-password"></i>
                            </div>
                            <input type="password" id="pwd" name="pwd" value="" lay-verify="required" placeholder="密   码" lay-reqtext="请填写密码" autocomplete="off" class="layui-input" lay-affix="eye">
                        </div>
                    </div>
                    <div class="layui-form-item">
                      <button id="btnlogin" class="layui-btn layui-btn-fluid">登录</button>
                    </div>
                    <div class="layui-form-item">
                        <a href="/register" style="float: left; margin-top: 7px;">新用户注册</a>
                        <input type="checkbox" name="remember" lay-skin="primary" title="记住密码">
                        <a href="#forget" style="float: right; margin-top: 7px;">忘记密码？</a>
                    </div>
                </div>
            </div>
        </div>
	</div>
</body>
</html>